package com.team7.order.controller;


import com.team7.order.entity.Chapter;
import com.team7.order.service.ChapterService;
import com.team7.order.utils.CommonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *
 * @author 张煜杰
 * @since 2021-10-22
 */
@RestController
@RequestMapping("/order/chapter")
@Api(tags = "ChapterController")
public class ChapterController {

    @Autowired
    private ChapterService chapterService;

    @PostMapping("findChapterByCourseId/{courseId}")
    public CommonResult findChapterByCourseId(@PathVariable String courseId){
         return chapterService.findChapterByCourseId(courseId);
    }
    @PostMapping("/findChapterById/{id}")
    public CommonResult findChapterById(@PathVariable String id){
        return chapterService.findChapterById(id);
    }

    @PostMapping("/insertChapterWithCourseId")
    public CommonResult insertChapter(@RequestBody Chapter chapter){
        return chapterService.insertChapter(chapter);
    }

    @PostMapping("/deleteChapterWithCourseId")
    public CommonResult deleteChapterWithCourseId(@RequestBody Chapter chapter){
        return chapterService.deleteChapterWithCourseId(chapter);
    }

}

